#pragma once
#include <string>
#include <list>
#include "JSerialize.h"
#include "JInOutPut.h"
#include "JStubArgument.h"

class JBaseFile : public JSerialize,public JStubArgument
{
public:
	JBaseFile(void);
	~JBaseFile(void);
	//Serialize begin.
	std::string filename;
	std::string createTime;
	std::string verifyTime;
        /*根据filename，去读取文件的其他信息，比如createTime等*/
        void FillFileInfo();
	//Serialize end.
	JBaseFile(std::string _fileName,std::string _createTime,std::string _verifyTime);
	JBaseFile(std::string _fileName);
	static bool HasChildBaseFile(std::string parentPath,std::string baseFileName);
	static bool HasGenerateFile(std::string ancestor,std::string _fileName);
	static bool IsExist(std::string _path);
	static bool CopyBaseFile(std::string oldFileName,std::string newFileName);
	static void ReName(std::string oldFileName,std::string newFileName);
        //统计所有的子目录
	static std::list<std::string> RecurseDownBaseFile(std::string _rootPath);
        static bool IsAncestor(const std::string& _ancestor,const std::string& _fileName);
        static std::list<std::string> GenerateAncestor(const std::string& path);
        /*比如把/repos/1/dir1/dir12修改为/repos/2/dir1/dir12
        strPath="/repos/1/dir1/dir12",index=1,destStr="2"*/
        static std::string ModifyPath(std::string strPath,int index,std::string destStr);
        /*判断两个路径是否相等，index是只从第几个开始，length指一共要比较几个*/
        static bool IsEqual(std::string strPath1,std::string strPath2,int index);
        static bool Compare(const std::string& _p1,const std::string& _p2);
	static std::string Absolute(std::string fileName);
	int Serialize(JInOutPut& _strea,int& allSize);
	int ReSerialize(JInOutPut& _strea);
        /*到远程服务器，建包*/
        int PackStubMessage(JInOutPut& _strea,int& _allSize);
        /*服务器解包*/
        int UnPackStubMessage(JInOutPut& _strea);
        /*把目录分成单个字符，比如"/repos/1/dir/dir2"分成["repos","1","dir","dir2"]*/
        static std::list<std::string> SplitPath(std::string _fileName);
        static std::string FileOrDir(std::string p);
};

